Commit 9eba4f95 authored by charras's avatar charras
Browse files

Solved a bug when creating a new zone outline that could crash pcbnew

parent 544ca4c9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.

2008-oct-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
    Solved a bug when creating a new zone outline that could crash pcbnew
    More about copper zones filled without grid (by polygons)
    Currently for tests only (work in progress).
    now working: Thermal reliefs parameters can be set.

2008-oct-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
+1019 B (159 KiB)

File changed.

No diff preview for this file type.

+131 −712

File changed.

Preview size limit exceeded, changes collapsed.

+39 −34
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
    m_Poly   = new CPolyLine();                 // Outlines
    m_ArcToSegmentsCount = 16;                  // Use 16 segment to convert a circle to a polygon
    m_DrawOptions = 0;
    m_ThermalReliefGapValue = 200;              // tickness of the gap in thermal reliefs
    m_ThermalReliefCopperBridgeValue = 200;     // tickness of the copper bridge in thermal reliefs
}


@@ -138,8 +140,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
    if( ret < 2 )
        return false;

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

@@ -274,9 +276,10 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
        {
            int gridsize = 50;
            int arcsegmentcount = 16;
            int drawopt = 'F';
            char drawopt = 'F';
            text = Line + 8;
            ret  = sscanf( text, "%d %d %c", &gridsize, &arcsegmentcount, &drawopt );
            ret  = sscanf( text, "%d %d %c %d %d", &gridsize, &arcsegmentcount, &drawopt,
                &m_ThermalReliefGapValue, &m_ThermalReliefCopperBridgeValue );
            if( ret < 1 )  // Must find 1 or more args.
                return false;
            else
@@ -287,7 +290,6 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )

            if( drawopt == 'S' )  // Sketch mode for filled areas in this zone selected
                m_DrawOptions = 1;

        }
        if( strnicmp( Line, "ZClearance", 10 ) == 0 )    // Clearence and pad options info found
        {
@@ -571,7 +573,7 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC,
    if( DC == NULL )
        return;
    int     curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
    int     color = g_DesignSettings.m_LayerColor[m_Layer] & MASKCOLOR;
    int     color = g_DesignSettings.m_LayerColor[m_Layer & 31] & MASKCOLOR;

    if( DisplayOpt.ContrastModeDisplay )
    {
@@ -585,27 +587,30 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC,

    // draw the lines
    wxPoint start_contour_pos = GetCornerPosition( 0 );
    for( int ic = 0; ic < GetNumCorners(); ic++ )
    int icmax = GetNumCorners() - 1;
    for( int ic = 0; ic <= icmax; ic++ )
    {
        int xi = GetCornerPosition( ic ).x;
        int yi = GetCornerPosition( ic ).y;
        int xf, yf;
        if( m_Poly->corner[ic].end_contour == FALSE && ic < GetNumCorners() - 1 )
        if( m_Poly->corner[ic].end_contour == FALSE && ic < icmax )
        {
            is_close_segment = false;
            xf = GetCornerPosition( ic + 1 ).x;
            yf = GetCornerPosition( ic + 1 ).y;
            if( (m_Poly->corner[ic + 1].end_contour) || (ic == GetNumCorners() - 2) )
            if( (m_Poly->corner[ic + 1].end_contour) || (ic == icmax - 1) )
                current_gr_mode = GR_XOR;
            else
                current_gr_mode = draw_mode;
        }
        else
        else    // Draw the line from last corner to the first corner of the current coutour
        {
            is_close_segment = true;
            current_gr_mode  = GR_XOR;
            xf = start_contour_pos.x;
            yf = start_contour_pos.y;
            // Prepare the next contour for drawing, if exists
            if ( ic < icmax )
                start_contour_pos = GetCornerPosition( ic + 1 );
        }
        GRSetDrawMode( DC, current_gr_mode );
+40 −38
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ public:
    int                   m_GridFillValue;                  // Grid used for filling, 0 = use polygonal areas to fill
    int                   m_ArcToSegmentsCount;             // number of segments to convert a cirlce to a polygon (uses 16 or 32)
    m_PadInZone           m_PadOption;                      // see m_PadInZone
    int                   m_ThermalReliefGapValue;          // tickness of the gap in thermal reliefs
    int                   m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
    int                   utility, utility2;                // flags used in polygon calculations
    std::vector <CPolyPt> m_FilledPolysList;  /* set of filled polygons used to draw a zone as a filled area.
                                               * from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole (they are all in one piece)
Loading