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

Pcbnew: bug fix: m_ZoneMinThickness parameter not copied in zone copy...

Pcbnew: bug fix: m_ZoneMinThickness parameter not copied in zone copy function. In copy block, copied zones have an erroneous m_ZoneMinThickness parmeter value.
parent e560573c
Loading
Loading
Loading
Loading
+122 −93
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@

ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
    BOARD_CONNECTED_ITEM( parent, TYPE_ZONE_CONTAINER )

{
    m_NetCode = -1;                             // Net number for fast comparisons
    m_CornerSelection = -1;
@@ -45,7 +44,6 @@ ZONE_CONTAINER::~ZONE_CONTAINER()
}



/**
 * Function GetPosition (virtual)
 * @return a wxPoint, position of the first point of the outline
@@ -53,24 +51,26 @@ ZONE_CONTAINER::~ZONE_CONTAINER()
wxPoint& ZONE_CONTAINER::GetPosition()
{
    static wxPoint pos;

    if( m_Poly )
    {
        pos = GetCornerPosition( 0 );
    }
    else pos = wxPoint(0,0);
    else
        pos = wxPoint( 0, 0 );
    return pos;
}


/*******************************************/
void ZONE_CONTAINER::SetNet( int anet_code )
{
/*******************************************/

/**
 * Set the netcode and the netname
 * if netcode >= 0, set the netname
 * if netcode < 0: keep old netname (used to set an necode error flag)
 */
{
    m_NetCode = anet_code;

    if( anet_code < 0 )
@@ -163,8 +163,13 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
    if( ret < 1 )
        return false;

    ret = fprintf( aFile, "ZOptions %d %d %c %d %d\n", m_FillMode, m_ArcToSegmentsCount,
        m_IsFilled ? 'S' : 'F', m_ThermalReliefGapValue, m_ThermalReliefCopperBridgeValue );
    ret = fprintf( aFile,
                   "ZOptions %d %d %c %d %d\n",
                   m_FillMode,
                   m_ArcToSegmentsCount,
                   m_IsFilled ? 'S' : 'F',
                   m_ThermalReliefGapValue,
                   m_ThermalReliefCopperBridgeValue );
    if( ret < 3 )
        return false;

@@ -186,7 +191,12 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
        for( unsigned ii = 0; ii < m_FilledPolysList.size(); ii++ )
        {
            const CPolyPt* corner = &m_FilledPolysList[ii];
            ret = fprintf( aFile, "%d %d %d %d\n", corner->x, corner->y, corner->end_contour,  corner->utility );
            ret = fprintf( aFile,
                           "%d %d %d %d\n",
                           corner->x,
                           corner->y,
                           corner->end_contour,
                           corner->utility );
            if( ret < 4 )
                return false;
        }
@@ -217,8 +227,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const

/**********************************************************/
int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
/**********************************************************/
{
/**********************************************************/
    char* Line, * text;
    char  netname_buffer[1024];
    int   ret;
@@ -363,7 +373,6 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
                }
            }
        }

        else if( strnicmp( Line, "ZMinThickness", 13 ) == 0 )    // Min Thickness info found
        {
            int thickness;
@@ -374,7 +383,6 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
            else
                m_ZoneMinThickness = thickness;
        }

        else if( strnicmp( Line, "$POLYSCORNERS", 13 ) == 0  )  // Read the PolysList (polygons used for fill areas in the zone)
        {
            while( aReader->ReadLine() )
@@ -385,7 +393,12 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
                CPolyPt corner;
                int     end_contour, utility;
                utility = 0;
                ret = sscanf( Line, "%d %d %d %d", &corner.x, &corner.y, &end_contour, &utility );
                ret     = sscanf( Line,
                                  "%d %d %d %d",
                                  &corner.x,
                                  &corner.y,
                                  &end_contour,
                                  &utility );
                if( ret < 4 )
                    return false;
                corner.end_contour = end_contour ? true : false;
@@ -393,7 +406,6 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
                m_FilledPolysList.push_back( corner );
            }
        }

        else if( strnicmp( Line, "$FILLSEGMENTS", 13 ) == 0  )
        {
            SEGMENT segm;
@@ -402,7 +414,12 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
                Line = aReader->Line();
                if( strnicmp( Line, "$endFILLSEGMENTS", 4 ) == 0  )
                    break;
                ret = sscanf( Line, "%d %d %d %d", &segm.m_Start.x, &segm.m_Start.y, &segm.m_End.x, &segm.m_End.y );
                ret = sscanf( Line,
                              "%d %d %d %d",
                              &segm.m_Start.x,
                              &segm.m_Start.y,
                              &segm.m_End.x,
                              &segm.m_End.y );
                if( ret < 4 )
                    return false;
                m_FillSegmList.push_back( segm );
@@ -438,8 +455,8 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, con
    BOARD*  brd   = GetBoard();
    int     color = brd->GetLayerColor( m_Layer );

    if( brd->IsLayerVisible( m_Layer ) == false &&
        ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
    if( brd->IsLayerVisible( m_Layer ) == false
        && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
        return;

    GRSetDrawMode( DC, aDrawMode );
@@ -486,6 +503,7 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, con
        lines.push_back( seg_start );
        lines.push_back( seg_end );
    }

    GRLineArray( &panel->m_ClipBox, DC, lines, 0, color );

    // draw hatches
@@ -509,8 +527,8 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, con
/************************************************************************************/
void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
                                     wxDC* DC, int aDrawMode, const wxPoint& offset )
{
/************************************************************************************/

/**
 * Function DrawDrawFilledArea
 * Draws the filled areas for this zone (polygon list .m_FilledPolysList)
@@ -519,7 +537,6 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
 * @param offset = Draw offset (usually wxPoint(0,0))
 * @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
 */
{
    static vector <char>    CornersTypeBuffer;
    static vector <wxPoint> CornersBuffer;

@@ -673,8 +690,8 @@ EDA_Rect ZONE_CONTAINER::GetBoundingBox() const

/**********************************************************************************************/
void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode )
{
/***********************************************************************************************/

/**
 * Function DrawWhileCreateOutline
 * Draws the zone outline when ir is created.
@@ -685,7 +702,6 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC,
 * @param DC = current Device Context
 * @param draw_mode = draw mode: OR, XOR ..
 */
{
    int     current_gr_mode  = draw_mode;
    bool    is_close_segment = false;
    wxPoint seg_start, seg_end;
@@ -877,6 +893,7 @@ 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.
@@ -887,28 +904,31 @@ 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 ) )
            if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend, aRefPos.x,
                                        aRefPos.y ) )
            {
                inside = true;
                break;
            }

            // Prepare test of next area which starts after the current indexend (if exists)
            indexstart = indexend + 1;
        }
    }

    return inside;
}



/************************************************************/
void ZONE_CONTAINER::DisplayInfo( WinEDA_DrawFrame* frame )
/************************************************************/
{
/************************************************************/
    wxString msg;

    BOARD*   board = (BOARD*) m_Parent;
@@ -1000,6 +1020,7 @@ void ZONE_CONTAINER::Move( const wxPoint& offset )
        corner->x += offset.x;
        corner->y += offset.y;
    }

    for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
    {
        m_FillSegmList[ic].m_Start += offset;
@@ -1043,6 +1064,7 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset )
void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle )
{
    wxPoint pos;

    for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
    {
        pos.x = m_Poly->corner[ii].x;
@@ -1064,6 +1086,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle )
        corner->x = pos.x;
        corner->y = pos.y;
    }

    for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
    {
        RotatePoint( &m_FillSegmList[ic].m_Start, centre, angle );
@@ -1071,6 +1094,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle )
    }
}


/**
 * Function Flip
 * Flip this object, i.e. change the board side for this object
@@ -1083,6 +1107,7 @@ void ZONE_CONTAINER::Flip(const wxPoint& aCentre )
    SetLayer( ChangeSideNumLayer( GetLayer() ) );
}


/**
 * Function Mirror
 * flip the outlines , relative to a given horizontal axis
@@ -1107,6 +1132,7 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
        NEGATE( corner->y );
        corner->y += mirror_ref.y;
    }

    for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
    {
        m_FillSegmList[ic].m_Start.y -= mirror_ref.y;
@@ -1134,6 +1160,7 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
    m_Poly->Copy( src->m_Poly );                // copy outlines
    m_CornerSelection  = -1;                    // For corner moving, corner index to drag, or -1 if no selection
    m_ZoneClearance    = src->m_ZoneClearance;  // clearance value
    m_ZoneMinThickness = src->m_ZoneMinThickness;
    m_FillMode = src->m_FillMode;               // Filling mode (segments/polygons)
    m_ArcToSegmentsCount = src->m_ArcToSegmentsCount;
    m_PadOption = src->m_PadOption;
@@ -1147,6 +1174,7 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
    m_FillSegmList = src->m_FillSegmList;
}


/**
 * Function SetNetNameFromNetCode
 * Find the net name corresponding to the net code.
@@ -1155,6 +1183,7 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
bool ZONE_CONTAINER::SetNetNameFromNetCode( void )
{
    NETINFO_ITEM* net;

    if( m_Parent && ( net = ( (BOARD*) m_Parent )->FindNet( GetNet() ) ) )
    {
        m_Netname = net->GetNetname();